package video

import (
	"context"
	"fmt"
	"go.mongodb.org/mongo-driver/bson/primitive"
	"go.mongodb.org/mongo-driver/mongo"
	"xia/demo/mongodb"
	model2 "xia/main/inedx/model"
)

func SetPoem(videoId string, videoName string, videoUrl string, videoType string) {
	var (
		client     = mongodb.MgoCli()
		err        error
		collection *mongo.Collection
		iResult    *mongo.InsertOneResult
		id         primitive.ObjectID
	)
	collection = client.Database("tiktok").Collection("video")

	stock := model2.Video{
		VideoId:   videoId,
		VideoName: videoName,
		VideoUrl:  videoUrl + videoName + "/" + videoId,
		VideoType: videoType,
	}

	if iResult, err = collection.InsertOne(context.TODO(), stock); err != nil {
		fmt.Print(err)
		return
	}
	id = iResult.InsertedID.(primitive.ObjectID)
	fmt.Println("自增ID", id.Hex())

}
